#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include <prepareMain.au3>


$font = "Arial"
$ini_file_name = @ScriptDir &"\config\GlobalSetting.ini"
$buildInfo_section = "Build Information"
GUI_Main()

func GUI_Main()

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("GUI for setting Globe Variable", 420, 450, 201, 118)
GUISetBkColor(0xA6CAF0)
;Action
$Change = GUICtrlCreateLabel("Action:", 40, 30, 50, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
$input_action = GUICtrlCreateInput(IniRead($ini_file_name, $buildInfo_section, "Action", "NA"), 300, -1, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
$Change = GUICtrlCreateLabel("(1:Install  2:Uninstall 3:Upgrade )", 40, 50, 280, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)

;IsFalconBuild
$Change = GUICtrlCreateLabel("Falconstor build:", 40, 90, 100, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
$input_falcon = GUICtrlCreateInput(IniRead($ini_file_name, $buildInfo_section, "Is_Falcon_Build", "NA"), 300, -1, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
$Change = GUICtrlCreateLabel("(0:Gengeric build 1:Falconstor build  )", 40, 110, 280, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)

;DiskSafe_Version
$Change = GUICtrlCreateLabel("DiskSafe version:", 40, 150, 100, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
$input_disksafe_version = GUICtrlCreateInput(IniRead($ini_file_name, $buildInfo_section, "DiskSafe_Version", "NA"), 300, -1, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
;$Change = GUICtrlCreateLabel("( Example: 3.5/3.62  )", 40, 170, 280, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)

;DiskSafe_Build
$Change = GUICtrlCreateLabel("DiskSafe build:", 40, 200, 100, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
$input_disksafe_build = GUICtrlCreateInput(IniRead($ini_file_name, $buildInfo_section, "DiskSafe_Build", "NA"), 300, -1, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
;$Change = GUICtrlCreateLabel("( Example: 240  )", 40, 220, 280, 20)
;GUICtrlSetFont(-1, 10, 400, 0, $font)

;IMA_Version
$Change = GUICtrlCreateLabel("IMA version:", 40, 250, 100, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
$input_ima_version = GUICtrlCreateInput(IniRead($ini_file_name, $buildInfo_section, "IMA_Version", "NA"), 300, -1, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
;$Change = GUICtrlCreateLabel("( Example: 2.50  )", 40, 220, 280, 20)
;GUICtrlSetFont(-1, 10, 400, 0, $font)

;IMA_build
$Change = GUICtrlCreateLabel("IMA build:", 40, 300, 100, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
$input_ima_build = GUICtrlCreateInput(IniRead($ini_file_name, $buildInfo_section, "IMA_Build", "NA"), 300, -1, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, $font)
;$Change = GUICtrlCreateLabel("( Example: 2.50  )", 40, 220, 280, 20)
;GUICtrlSetFont(-1, 10, 400, 0, $font)


$write = GUICtrlCreateButton("set", 40, 350, 75, 25, $WS_GROUP)
GUICtrlSetFont(-1, 12, 400, 0, $font)

$run = GUICtrlCreateButton("run", 265,350, 75, 25, $WS_GROUP)
GUICtrlSetFont(-1, 12, 400, 0, $font)


GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###


While 1

$nMsg = GUIGetMsg()
	Switch $nMsg

		Case $GUI_EVENT_CLOSE
				Exit

		Case $write
				IniWrite($ini_file_name, "Global Variables", "Action", GUICtrlRead ($input_action))
				IniWrite($ini_file_name, "Global Variables", "IsFalconBuild", GUICtrlRead ($input_falcon))
				IniWrite($ini_file_name, "Global Variables", "DiskSafe_Version", GUICtrlRead ($input_disksafe_version))
				IniWrite($ini_file_name, "Global Variables", "DiskSafe_Build", GUICtrlRead ($input_disksafe_build))
				IniWrite($ini_file_name, "Global Variables", "IMA_Version", GUICtrlRead ($input_ima_version))
				IniWrite($ini_file_name, "Global Variables", "IMA_Build", GUICtrlRead ($input_ima_build))


		Case $run
				$var=IniRead($ini_file_name, "Global Variables", "Action", GUICtrlRead ($input_action))
				GUIDelete()
				prepareMain()

	EndSwitch
WEnd

EndFunc
